<?php

/**
 * Stores the current version details of the application
 *
 * This class will be accessed statically so the methods should reflect this
 * The numbers stored within this file should be updated everytime a release-tag
 * is created
 * 
 * @author Ben Rowe
 */
class Version
{
	/**
	 * Stores the svn (or repositiory) version of the application
	 * 
	 * @access private
	 * @var integer
	 */
	var $_revision = 82;
	
	/**
	 * Major version number
	 *
	 * @access private
	 * @var int
	 */
	var $_major	= 1;
	
	/**
	 * Minor version number
	 *
	 * @access private
	 * @var int
	 */
	var $_minor	= 0;
	
	/**
	 * Bug version number
	 *
	 * @access private
	 * @var int
	 */
	var $_bug	= 0;
	
	/**
	 * Builds a (short)version string for displaying
	 *
	 * @access public
	 * @return string
	 */
	function getVersion()
	{
		// just build a simple version string
		return $this->_major.'.'.$this->_minor.'.'.$this->_bug.'.r'.$this->_revision;
	}
	
	/**
	 * Each part of the version is an element of the returned array
	 *
	 * @access public
	 * @return array
	 */
	function getVersionArray()
	{
		return array($this->_major, $this->_minor, $this->_bug, $this->_revision);
	}
	
	/**
	 * Build a integer of the major, minor & bug, to be used for comparisons
	 *
	 * @access public
	 * @return int
	 */
	function getSimple()
	{
		return intval($this->_major.$this->_minor.$this->_bug);
	}
	
	/**
	 * Compares another version object's version to this object's version.
	 * If the compared ($version) is > then 1 is returned,
	 * If the compared is < then -1 is returned
	 * If the compared version is the same then 0 is returned
	 *
	 * @param Version $version
	 * @return int
	 * @todo Add the logic for the greater/lesser than
	 */
	function compareTo($version)
	{
		$theres = $version->getSimple();
		$ours	= $this->getSimple();
		
		if($theres === $ours) return 0; // if the contents of the array match each other
		
		if($theres > $ours) {
			return 1;
		}
		
		return -1;
		
	}
	
	
}

?>